package com.antu.first.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * Created by 王一山 on 2018/3/10.
 */
public class EncodingFilter implements javax.servlet.Filter {

    private String adg;
    public EncodingFilter() {

    }
    public void destroy() {

    }
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        request.setCharacterEncoding(this.adg);
        response.setCharacterEncoding(this.adg);
        chain.doFilter(request, response);
    }
    public void init(FilterConfig fcg) throws ServletException {
        this.adg=fcg.getInitParameter("encoding");
    }
}
